﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using Slex.Timeline;
using Slex;
using System.Windows.Threading;

namespace Test.Scenes {
    public partial class Cartoon3 : Page {
        public Cartoon3() {
            InitializeComponent();
            r1 = new Rectangle[len];
            r2 = new Rectangle[len];
            r3 = new Rectangle[len];
            r4 = new Rectangle[len];
            r = new Rectangle[len * 4];
            for (int i = 0; i < r1.Length; i++) { r1[i] = new Rectangle(); r1[i].HorizontalAlignment = System.Windows.HorizontalAlignment.Left; r1[i].Height = 12; r1[i].Stroke = Brushs.Coral.ToBrush(); r1[i].Fill = Brushs.DarkGreen.ToBrush(); sp1.Children.Add(r1[i]); }
            for (int i = 0; i < r2.Length; i++) { r2[i] = new Rectangle(); r2[i].HorizontalAlignment = System.Windows.HorizontalAlignment.Center; r2[i].Height = 12; r2[i].Stroke = Brushs.Coral.ToBrush(); r2[i].Fill = Brushs.DarkGreen.ToBrush(); sp2.Children.Add(r2[i]); }
            for (int i = 0; i < r3.Length; i++) { r3[i] = new Rectangle(); r3[i].HorizontalAlignment = System.Windows.HorizontalAlignment.Center; r3[i].Height = 12; r3[i].Stroke = Brushs.Coral.ToBrush(); r3[i].Fill = Brushs.DarkGreen.ToBrush(); sp3.Children.Add(r3[i]); }
            for (int i = 0; i < r4.Length; i++) { r4[i] = new Rectangle(); r4[i].HorizontalAlignment = System.Windows.HorizontalAlignment.Right; r4[i].Height = 12; r4[i].Stroke = Brushs.Coral.ToBrush(); r4[i].Fill = Brushs.DarkGreen.ToBrush(); sp4.Children.Add(r4[i]); }
            r1.CopyTo(r, 0);
            r2.CopyTo(r, len);
            r3.CopyTo(r,len*2);
            r4.CopyTo(r, len*3);
            Loaded += Cartoon3_Loaded;
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Tick += timer_Tick; ran = new Random();
        }
        EntityxsAction ea; Random ran;
        void timer_Tick(object sender, EventArgs e) {
            for (int i = 0; i < r.Length; i++) {
                ea[i].Valued = ran.Next(200);
            }
            ea.Storyboard.Begin();
        }
        DispatcherTimer timer;
        void Cartoon3_Loaded(object sender, RoutedEventArgs e) {
            ea = Cartoon.Actions(new TlArgument(150,ct:CartoonType.Width), r);
            timer.Start();
        }
        Rectangle[] r1, r2, r3, r4,r;
        int len = 25;
    }
}
